<template>
	<view class="con-box">
		<u-navbar title="" height="120upx">
			<view class="u-nav-slot" slot="left">
				<view @tap="back" class="icon-left">
					<u-icon name="arrow-left" color="#fff" size="26"></u-icon>
				</view>
			</view>
			<view class="u-nav-slot logoBox" slot="center">
				<view class="navBox">我的反馈</view>
			</view>
			<view class="u-nav-slot" slot="right">
				<view class="icon-right">
				</view>
			</view>
		</u-navbar>
		
		<view class="tab-list">
			<scroll-view class="listview" enableBackToTop="true" scroll-y @scrolltolower="scrolltolower()">
				<view class="list-item" v-for="(item,index) in tabList" :key="index" @tap="navTo(2,item)">
					<view>{{item.infos}}</view>
					<text>{{moment(item.modified).format('yy-MM-DD HH:mm:ss')}}</text>
				</view>
			</scroll-view>
			<view class="nodeData" v-if="tabList.length == 0">
				<image src="../../static/user/nodeFeedback.png" mode="widthFix"></image>
				<view>无反馈信息</view>
				<text>您目前还没有反馈过任何内容</text>
			</view>
		</view>
		<mix-loading ref="min_loading"></mix-loading>
	</view>
</template>

<script>
	import {getFreedbackList} from '@/api/user.js'
	export default {
		data(){
			return {
				tabList:[],
				listQuery: {
					page: 1,
					pageSize: 10,
					pages:1,
					userType:1
				},
			}
		},
		onLoad() {
			this.getNewsData();
		},
		methods:{
			scrolltolower(){
				if(this.listQuery.pages > this.listQuery.page){
					this.listQuery.page++;
					this.getNewsData();
				}
			},
			getNewsData() {
				this.$nextTick(()=>{
					this.$refs.min_loading.open('加载中，请稍后！');
				});
				getFreedbackList(this.listQuery).then(res => {
					this.listQuery.pages = res.data.totalPage;
					if(res.data.rows){
						let newList = res.data.rows.filter((item, index) => {
							// if(item.fileUrl){
							// 	item.fileUrl = (this.pathImg + item.fileUrl);
							// }
							// if(item.metafile){
							// 	item.metafile = JSON.parse(item.metafile);
							// }
							return item;
						});
						
						if (this.listQuery.page == 1) {
							this.tabList = [...newList];
						} else {
							this.tabList = [...this.tabList,...newList];
						}
					}
				}).finally(() => {
					this.$refs.min_loading.close();
				});
			},
			back(){
				let canNavBack = getCurrentPages();
				if(canNavBack && canNavBack.length>1) {  
				    uni.navigateBack({  
				      delta: 1  
				    });  
				} else {  
				    history.back();  
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		width: 100%;
		height: 100%;
	}
	.con-box {
		min-height: 100vh;
		padding: 140upx 0upx 20upx;
		width: 100%;
		height: 100%;
		.logoBox{
			width: 100%;
			height: 100%;
			.navBox{
				height: 120upx;
				background-image: url("@/static/common/bg1.png");
				background-size: 100% 100%;
				background-repeat: no-repeat;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
			}
		}
		
		.tab-list{
			width: 100%;
			height: 100%;
			.listview{
				width: 100%;
				height: 100%;
			}
			.nodeData{
				text-align: center;
				padding-top: 400upx;
				image{
					width: 90upx;
				}
				text{
					font-size: 30upx;
					color: #999;
				}
				view{
					font-size: 40upx;
					color: #333;
					margin-top: 34upx;
					margin-bottom: 36upx;
				}
			}
			.list-item{
				font-size: 30upx;
				color: #333;
				margin-bottom: 20upx;
				padding:40upx 30upx;
				background-color: #fff;
				>text{
					display: inline-block;
					line-height: 24upx;
					font-size: 24upx;
					text-align: left;
					color: #999;
				}
				>view{
					padding-bottom: 30upx;
					text-align: justify;
				}
			}
		}
		
	}
</style>
